

use "$data/survey1_clean.dta", clear

global control male age_* log_inc log_inc_sq highschool college working student democrat republican 

*** Manip check ***

loc experiments "z_impact_1 z_impact_2"
		   
			   
preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""

global output_coeff ""
global output_se ""
global output_name""

foreach choice in `experiments' {

/* Statistics */

	
 xi:  reg `choice' highmort , vce(r)

 
    sigstar highmort, prec(4)
    estadd loc thisstat3 = "`r(bstar)'": col`colnum'
    estadd loc thisstat4 = "`r(sestar)'": col`colnum'
	

    estadd loc thisstat6 =  string(`e(r2)', "%9.2f"): col`colnum'
	

	qui sum `choice'  
	estadd loc thisstat7 =  r(N): col`colnum'
	
	 xi:  reg `choice' highmort $control , vce(r)

 
 
    sigstar highmort, prec(4)
    estadd loc thisstat12 = "`r(bstar)'": col`colnum'
    estadd loc thisstat13 = "`r(sestar)'": col`colnum'
	
 
    estadd loc thisstat15 =  string(`e(r2)', "%9.2f"): col`colnum'

	qui sum `choice'  
	estadd loc thisstat16 =  r(N): col`colnum'
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"

	} 
	

loc rowlabels " "{\bf Panel A: No control variables} " " " "High relative mortality" " "  " "   "\midrule R$^2$" " Number of Observations " "\midrule" " " "{\bf Panel B: Including control variables} " " " "High relative mortality" " "  " " "\midrule R$^2$" " Number of Observations ""
loc rowstats ""

forval i = 1/16 {
    loc rowstats "`rowstats' thisstat`i'"
}




esttab * using "$tables/experiment_mainpart1_combined.tex", replace cells(none) booktabs nonotes compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
   mtitle("World" "US"    ) ///
   mgroups("Predicted impact on (standardized)" ,  pattern(1 0  1 0   ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
